package 网易互娱;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(bf.readLine());
        for (int i = 0; i < t; i++) {
            String[] strs = bf.readLine().split(" ");
            long L = Long.parseLong(strs[0]);
            long R = Long.parseLong(strs[1]);
            System.out.println(getMin(L,R));
        }
    }

    public static Long getMin(Long L,Long R){
        long shift = 0;
        while(L< R){
            L >>= 1;
            R >>= 1;
            shift++;
        }
        return L<< shift;
    }
}
